// Filename: router.js
define([
    'jQuery',
    'Underscore',
    'Backbone',
    'Kendo',
    'Bootstrap',
    'views/home/main',
    'views/home/guitest',
    'views/home/settings',
    'text!templates/home/settings.html',
    'views/registration/new',
    'text!templates/registration/new.html'
], function($, 
            _, 
            Backbone, 
            Kendo, 
            Bootstrap, 
            mainHomeView, 
            guiTestView, 
            settingsOverviewView,
            settingsOverviewTemplate,
            registrationNewView, 
            registrationNewTemplate){
    


    var VtaRouter = Backbone.Router.extend({
        
        routes: {
            // Define some URL routes
            'guitest': 'showGuiTest',
            'settings': 'showSettingsOverview',
            'registration/new': 'showRegistrationNew',
      
            // Default
            '*actions': 'defaultAction'
        },
    
        
        
        showRegistrationNew: function() {
            
            /* var regView = new registrationNewView(); */
            var templateRegistration = Kendo.template(registrationNewTemplate);
            $("#content").html(templateRegistration(registrationNewView));
            
            Kendo.bind($("#content"), registrationNewView);
            
            registrationNewView.renderSubviews();
            
            
                          
        },
        
        
        
        showSettingsOverview: function() {
            
            /* var settingsView = new settingsOverviewView(); */
            var templateSettings = Kendo.template(settingsOverviewTemplate);
            $("#content").html(templateSettings(settingsOverviewView));
            
            settingsOverviewView.renderSubviews();
            
            Kendo.bind($("#content"), settingsOverviewView);
            
            
//            var templateTree = Kendo.template(treeNewTemplate);
//            $("#tree_new").html(templateTree(treeNewView));
//            
//            treeNewView.renderSubviews();
//            
//            Kendo.bind($("#tree_new"), treeNewView);
              
        },
        
        
        
        showGuiTest: function() {

            guiTestView.render();
            
        }, 
        
        
    
        defaultAction: function(actions){

            // We have no matching route, lets display the home page 
            mainHomeView.render(); 
        }
  
    }); // var AppRouter = Backbone.Router.extend

  
  
    var initialize = function(){
        
        var vta_router = new VtaRouter;
        
        Backbone.history.start();
        
        // Expose jQuery to the global object
        window.jQuery = window.$ = jQuery = $;
        
    };
  
  

    return { 
        initialize: initialize
    };



});